#ifndef CLOGGER_H
#define CLOGGER_H

#include "CommDef.h"
#include <stdint.h>
#include <ctype.h>
#include <sys/types.h>
#include <stdarg.h>

class CLogger {
public:
	static void logInit();
	static void logStderr(int iError, const char* pszfmt, ...);
	static void logErrorCore(int iLevel, int iError, const char* pszFmt, ...);
	static u_char* logErrno(u_char* pszBuf, u_char* pszLast, int iError);

	// 打印相关
	static u_char* slprintf(u_char* pszBuf, u_char* pszLast, const char* pszFmt, ...);
	static u_char* snprintf(u_char* pszBuf, size_t uMax, const char* pszFmt, ...);
	static u_char* vslprintf(u_char* pszBuf, u_char* pszLast, const char* pszFmt, va_list args);
	static u_char* sprintfNum(u_char* pBuf, u_char* pLast, uint64_t ui64, u_char zero, uintptr_t hexDecimal, uintptr_t width);
	static void deInit();

private:
	CLogger() = delete;
	~CLogger() = delete;

	static int m_snLogLevel;	// 日志级别
	static int m_snLogFd;		// 文件描述符
	static char m_szErrLevels[][20];
};

#endif